abidibo.net

Deploy django application, set up another machine

deploy django git pip programming virtualenv

This entry is related to the series "Deploy django applications with nginx, uwsgi, virtualenv, south, git and fabric", the first part here.

So what happens here? Really nothing special, I've changed my working machine and so I had to set up my django projects on the new notebook. This post is only a remainder of the followed steps.

Install all the required system packages

Clearly I had to install some packages in the new machine:

  • mysql-server
  • python
  • python-dev
  • python-setuptools
  • build-essentials
  • libmysqlclient-dev
  • git

And also I've installed pip and virtualenv

Create the folder structure and the virtualenv

First of all create a directory which will contain the project, I've created it under /var/www:

$ mkdir /var/www/myproject

Create a new vitualenv:

$ cd /var/www/myproject
$ mkdir venv
$ cd venv
$ virtualenv --no-site-packages .

Clone the remote repository

I had to clone the remote bare repository through ssh:

$ cd /var/www/myproject
$ git clone ssh://USER@HOST/path/to/bare/repository.git ./myproject

Now I have all the python code, great!

Install all project's requirements

Let's activate the virtualenv and install all the requirements with pip

$ source /var/www/myproject/venv/bin/activate
(venv) $ cd /var/www/myproject/myproject
(venv) $ pip install -r requirements.txt

Ok now we have django and all the packages needed installed in the virtualenv. But... we need a database!

Create a database, update settings.py and migrate

Create a database and update the settings.py file with the new db_name, then let's go with the db migration:

(venv) $ cd /var/www/myproject/myproject
(venv) $ python manage.py syncdb --noinput --migrate

Yeah, the db structure is up to date... but wait, I've no data inside it.. this is not really a problem, since one of the features of this deployment approach is that the synchronization process does not affect the applications' data (the production web application is constantly upgraded with new contents...), so I'll charge only the data hat I want to manually, but indeed I need at least the super admin account, so let's create it:

(venv) $ python manage.py createsuperuser

Test it

It's time to test the web application in locale

(venv) $ python manage.py runserver

Ok all is working as expected

Subscribe to abidibo.net!

If you want to stay up to date with new contents published on this blog, then just enter your email address, and you will receive blog updates! You can set you preferences and decide to receive emails only when articles are posted regarding a precise topic.

I promise, you'll never receive spam or advertising of any kind from this subscription, just content updates.

Subscribe to this blog

Comments are welcome!

blog comments powered by Disqus

Your Smartwatch Loves Tasker!

Your Smartwatch Loves Tasker!

Now available for purchase!

Featured